// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Appp from './App'
import router from './router'
import VueResource from 'vue-resource'
import Toast from "./components/common/toast/toast"
import './components/common/toast/toast.css'
import lazyload from "./components/common/lazyload/lazyload"
import tap from "./components/common/tap/tap"
import Vuex from 'vuex';
import zh_CN from 'vee-validate/dist/locale/zh_CN'
import VeeValidate from 'vee-validate'
import { Validator } from 'vee-validate';

import pageModule from './store/modules/pageModule'
import productModule from './store/modules/productModule'
import userModule from './store/modules/userModule'

import validate from './components/common/validate/validate.js'

import { Progress } from 'element-ui'

import { Form } from 'element-ui'
import { FormItem } from 'element-ui' 
import { Input } from 'element-ui' 
import { Button } from 'element-ui' 
import { DatePicker } from 'element-ui'
import { Transfer } from 'element-ui'

// import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'


Vue.config.productionTip = false
Vue.use(VueResource)
Vue.use(Toast)
Vue.use(lazyload);
Vue.use(tap);
Vue.use(Vuex);
Vue.use(validate);
// Vue.use(ElementUI)

Vue.use(Progress)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Input)
Vue.use(Button)
Vue.use(DatePicker)
Vue.use(Transfer)

// 添加中文包
Validator.addLocale(zh_CN);
// 自定义手机提醒
Validator.extend('mobile', {
    messages: {
      zh_CN:field => '必须是11位手机号码',
    },
    validate: value => {
      return value.length == 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/.test(value)
    }
});
Validator.extend('pass', {
    messages: {
      zh_CN:field => '必须是6位数密码',
    },
    validate: value => {
      return value.length == 6 
    }
});
Validator.extend('nextPass', {
    messages: {
      zh_CN:field => '必须输入一致的密码',
    },
    validate: value => {
      return !/[`~]/.test(value)
    }
});
// 自定义提示语句
const dictionary = {
  zh_CN: {
    messages: {
      name1: () => '邮箱格式不正确哦',
      required: () => '为必填'
    }
  }
};
Validator.updateDictionary(dictionary);
// Vue.use(VeeValidate);
Vue.use(VeeValidate, {
  locale: 'zh_CN',
  events: 'blur'
})

//定义vuex
const vuex_store = new Vuex.Store({
  modules:{
    page:pageModule,
    product:productModule,
    username:userModule
  }
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  store:vuex_store,          //把vuex注入到实例中
  router,
  template: '<Appp/>',
  components: { Appp },
  methods:{
  }
})
